//
//  APPUtilsMacro.h
//  EKOOBase
//
//  Created by chenyf on 16/4/1.
//  Copyright © 2016年 ekoo. All rights reserved.
//


/*
 http://www.uphome.cn:9090/router/upload_idcard    这个是上传身份证的
 http://www.uphome.cn:9090/router/upload_workimg   这个是其他图片上传的
 */

// 喵师傅
#define kMSFTPID @"2797013908"

// fir.im
// 634686645@qq.com
//#define kFirAppID @"58c764eaca87a866340003df"
//#define kFirUserToken @"a1396ccac776db7feb95b01937352837"

// yanyi@dongjian.com.cn
#if defined (ADDFACTORYTEST)
//测试的
#define kFirAppID @"59103fb4959d6927a70000f0"
#define kFirUserToken @"1b81eb88e7aa90aacbedb733c3be66cf"
//#define kBaseURLString @"http://61.164.47.179:8888/jiagc_test/sys/proc/jiagcProxy.jsp"  //沙箱环境
#define kBaseURLString @"http://10.86.10.6:7380/jiagc_test/sys/proc/jiagcProxy.jsp"

#else
//正式的
#define kFirAppID @"592e25fdca87a8660e000196"
#define kFirUserToken @"f2a70e52cc2f6f92edbd613539e8b724"
#define kBaseURLString @"http://61.164.47.179:81/jiagc/sys/proc/jiagcProxy.jsp"  //正式环境

#endif


#define RowHeight 160

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define UIColorFromRGBA(rgbValue, alphaValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:alphaValue]

#define CheckStringNil(value) ((value) == nil? @"": (value))
#define CheckArrayNil(value)  ((value) == nil? @[]: (value))

#define Screen_Width [[UIScreen mainScreen] bounds].size.width
#define Screen_Height [[UIScreen mainScreen] bounds].size.height
#define Screen_Base_Width 375.0
#define Scale_Ratio Screen_Width / Screen_Base_Width

// MARK: - Font size based on 750 width
#define FontSize8  8.f  * Scale_Ratio
#define FontSize9  9.f  * Scale_Ratio
#define FontSize10 10.f  * Scale_Ratio
#define FontSize11 11.f * Scale_Ratio
#define FontSize12 12.f * Scale_Ratio
#define FontSize13 13.f * Scale_Ratio
#define FontSize14 14.f * Scale_Ratio
#define FontSize15 15.f * Scale_Ratio
#define FontSize16 16.f * Scale_Ratio
#define FontSize17 17.f * Scale_Ratio
#define FontSize18 18.f * Scale_Ratio
#define FontSize19 19.f * Scale_Ratio
#define FontSize20 20.f * Scale_Ratio
#define FontSize22 22.f * Scale_Ratio
#define FontSize23 23.f * Scale_Ratio
#define FontSize24 24.f * Scale_Ratio
#define FontSize25 25.f * Scale_Ratio
#define FontSize26 26.f * Scale_Ratio
#define FontSize30 30.f * Scale_Ratio
#define FontSize35 35.f * Scale_Ratio
#define FontSize50 50.f * Scale_Ratio


#define NOTIFICATION_DEFAULTCENTER  [NSNotificationCenter defaultCenter]
#define IS_IPHONE_4 (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double )480) < DBL_EPSILON )
#define IS_IPHONE_5 (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double )568) < DBL_EPSILON )


// 颜色
#define XMGARGBColor(a, r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)/255.0]
#define XMGColor(r, g, b) XMGARGBColor(255, (r), (g), (b))
#define XMGGrayColor(v) XMGColor((v), (v), (v))
#define XMGCommonBgColor XMGGrayColor(215)
#define XMGRandomColor XMGColor(arc4random_uniform(255), arc4random_uniform(255), arc4random_uniform(255))

// MARK COLOR
#define ImageViewBgColor UIColorFromRGB(0xEEEDE9)

#define StrsFontSize(str, font, constraintSize) ([(str) boundingRectWithSize:constraintSize options:(NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin| \
    NSStringDrawingUsesFontLeading) attributes:@{NSFontAttributeName:font} context:nil].size)

#define SVPHUDAlert(msg, isError, completion) while(1) {     \
double delayInSeconds = MIN((float)(msg).length*0.06 + 0.5, 5.0);    \
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); \
isError? [SVProgressHUD showErrorWithStatus:(msg)]: [SVProgressHUD showSuccessWithStatus:(msg)];\
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){  \
[SVProgressHUD dismiss];  \
if((completion)) (completion)(); \
}); \
break; }


// MARK: - Block Helper
#if NS_BLOCKS_AVAILABLE
#define SAFE_BLOCK_CALL_NO_P(b) (b == nil ?: b())
#define SAFE_BLOCK_CALL_ONE_P(b, p) (b == nil ? : b(p) )
#define SAFE_BLOCK_CALL_TWO_P(b, p1, p2) (b == nil ? : b(p1, p2) )
#define SAFE_BLOCK_CALL_THREE_P(b, p1, p2, p3) (b == nil ? : b(p1, p2, p3) )
#endif
